<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%--
<html>
<head>
	<title>车道信息管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/lane/lane/">车道信息列表</a></li>
		<shiro:hasPermission name="lane:lane:edit"><li><a href="${ctx}/lane/lane/form">车道信息添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="lane" action="${ctx}/lane/lane/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>车道名称：</label>
				<form:input path="laneName" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>区域名称</th>
				<th>车道名称</th>
				<th>车道总车位</th>
				<th>车道剩余车位</th>
			&lt;%&ndash;<th>更新时间</th>&ndash;%&gt;
				<shiro:hasPermission name="lane:lane:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="lane">
			<tr>
				<td>
					${lane.areaName}
				</td>
				<td><a href="${ctx}/lane/lane/form?id=${lane.id}">
					${lane.laneName}
				</a></td>
				<td>
					${lane.totalSpace}
				</td>
				<td>
					${lane.remainSpace}
				</td>
				&lt;%&ndash;<td>&ndash;%&gt;
					&lt;%&ndash;<fmt:formatDate value="${lane.updateTime}" pattern="yyyy-MM-dd HH:mm:ss"/>&ndash;%&gt;
				&lt;%&ndash;</td>&ndash;%&gt;
				<shiro:hasPermission name="lane:lane:edit"><td>
    				<a href="${ctx}/lane/lane/form?id=${lane.id}">修改</a>
					<a href="${ctx}/lane/lane/delete?id=${lane.id}" onclick="return confirmx('确认要删除该车道信息吗？', this.href)">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>--%>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css" media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/style.css" media="all">
	<script src="${pageContext.request.contextPath}/layui/layui.all.js"></script>
</head>
<body>
<div class="layadmin-header">
	<div class="layui-breadcrumb" lay-filter="breadcrumb">
		<a><cite>车道信息配置</cite></a>
	</div>
</div>

<div class="layui-fluid mainBody">
	<div class="layui-row">
		<div>
			<table class="layui-hide" id="test" lay-filter="test"></table>
		</div>
	</div>
</div>
</body>
</html>

<script>
	var $ = layui.$,
			admin = layui.admin,
			table = layui.table;

	var test = table.render({
		elem: '#test',
		url: '${pageContext.request.contextPath}/lane/getLaneList',
		// where: '',
		method: 'post',
		toolbar: '<div><a class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon layui-icon-add-1"></i>新增</a><a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a></div>',
		skin: 'line',
		size: 'lg',
		cols: [
			[{
				type: 'checkbox'
			},	{
				field: 'areaName',
				title: '区域'
			},  {
				field: 'laneNum',
				title: '车道编号'
			},{
				field: 'laneName',
				title: '车道名称'
			}, {
				field: 'remainSpace',
				title: '剩余车位'
			}, {
				field: 'totalSpace',
				title: '总车位'
			}, {
				field: '',
				width: 135,
				align: 'center',
				title: '操作',
				templet: function(data) {
					return '<a class="layui-btn layui-btn-sm layui-btn-normal" lay-event="edit">编辑</a><a class="layui-btn layui-btn-sm layui-btn-normal" lay-event="del">删除</a>';
				}
			}]
		],
		page: true,
		response: {
			statusName: 'code' //规定数据状态的字段名称，默认：code
			,statusCode: 200 //规定成功的状态码，默认：0
			,msgName: 'msg' //规定状态信息的字段名称，默认：msg
			,countName: 'total' //规定数据总数的字段名称，默认：count
			,dataName: 'data' //规定数据列表的字段名称，默认：data
		},
		request: {
			pageName: 'curr' //页码的参数名称，默认：page
			,limitName: 'nums' //每页数据量的参数名，默认：limit
		}
	});
	//头工具栏事件
	table.on('toolbar(test)', function(obj) {
		var data = table.checkStatus(obj.config.id).data;
		switch (obj.event) {
			case 'add':
				layer.open({
					type: 2,
					title: false,
					shade: 0.8,
					area: ['600px', '400px'],
					content: '${pageContext.request.contextPath}/iframe/setInfoItem.html?type=add',
					end: function() {
						test.reload();
					}
				});
				break;
			case 'del':
			    var ids=[];
			    data.forEach(function (e) {
                    ids.push(e.id);
                });
                del(ids.join(","));
				break;
		}
	});
	//行工具栏事件
	table.on('tool(test)', function(obj) {
		var data = obj.data;
		switch (obj.event) {
			case 'edit':
				layer.open({
					type: 2,
					title: false,
					shade: 0.8,
					area: ['600px', '400px'],
					content: '${pageContext.request.contextPath}/iframe/setInfoItem.html?type=edit&id='+data.id,
					end: function() {
						test.reload();
					}
				});
				break;
			case 'del':
                del(data.id);
				break;
		}
	});

    function del(ids) {
        layer.confirm("确定要删除",function () {
            $.ajax({
                type:"post",
                url:"${pageContext.request.contextPath}/lane/delete",
                data:{id:ids},
                success:function (res) {
                    if (res=='200'){
                        layer.msg("删除成功",{'icon':1,'offset': '100px'});
                    }
                    if (res=='201'){
                        layer.msg("删除失败",{'icon':5,'offset': '100px'});
                    }
                    test.reload();
                }
            })
        })
    }
</script>